package com.example.questionnaire.mbg.service.impl;

import com.example.questionnaire.mbg.entity.User;
import com.example.questionnaire.mbg.mapper.UserMapper;
import com.example.questionnaire.mbg.service.IUserService;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Primary
@Service
public class UserServiceImpl implements IUserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public User selectUserByUsername(String username) {
        return userMapper.getByUsername(username);
    }

    @Override
    public void register(String username, String password) {
        userMapper.register(username, password);
    }

    @Override
    public void changeUserPassword(String username, String newPassword) {
        userMapper.changePassword(username, newPassword);
    }

    @Override
    public void logout(String username) {
        userMapper.logout(username);
    }

    @Override
    public void login(String username) {
        userMapper.login(username);
    }

    @Override
    public boolean existsUser(int uid) {
        return false;
    }

    @Override
    public User selectUserByID(int uid) {
        return userMapper.get(uid);
    }
}